load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "argument_data",
    hdrs = ["argument_data.h"],
    deps = [
        ":synthesizer",
        "//tachyon/base:logging",
        "//tachyon/base:parallelize",
        "//tachyon/base/buffer:copyable",
        "//tachyon/base/containers:container_util",
        "//tachyon/math/base:parallelize_threshold",
        "//tachyon/zk/plonk/base:multi_phase_ref_table",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_library(
    name = "blake2b_transcript",
    hdrs = ["blake2b_transcript.h"],
    deps = [
        ":constants",
        ":prime_field_conversion",
        ":proof_serializer",
        "//tachyon/crypto/transcripts:transcript",
        "@com_google_absl//absl/types:span",
        "@com_google_boringssl//:crypto",
    ],
)

tachyon_cc_library(
    name = "bn254_gwc_prover_test",
    testonly = True,
    hdrs = ["bn254_gwc_prover_test.h"],
    deps = [
        ":prover_test",
        ":proving_scheme",
        "//tachyon/math/elliptic_curves/bn/bn254",
        "//tachyon/math/elliptic_curves/bn/bn254/halo2:bn254",
        "//tachyon/zk/base/commitments:gwc_extension",
    ],
)

tachyon_cc_library(
    name = "bn254_shplonk_prover_test",
    testonly = True,
    hdrs = ["bn254_shplonk_prover_test.h"],
    deps = [
        ":prover_test",
        ":proving_scheme",
        "//tachyon/math/elliptic_curves/bn/bn254",
        "//tachyon/math/elliptic_curves/bn/bn254/halo2:bn254",
        "//tachyon/zk/base/commitments:shplonk_extension",
    ],
)

tachyon_cc_library(
    name = "c_prover_impl_base_forward",
    hdrs = ["c_prover_impl_base_forward.h"],
)

tachyon_cc_library(
    name = "config",
    srcs = ["config.cc"],
    hdrs = ["config.h"],
    deps = [
        ":vendor",
        "//tachyon:export",
    ],
)

tachyon_cc_library(
    name = "constants",
    hdrs = ["constants.h"],
)

tachyon_cc_library(
    name = "pcs_type",
    hdrs = ["pcs_type.h"],
    deps = [
        "//tachyon/base/flag",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "pinned_constraint_system",
    hdrs = ["pinned_constraint_system.h"],
    deps = [
        ":pinned_gates",
        "//tachyon/zk/plonk/constraint_system",
        "//tachyon/zk/plonk/halo2/stringifiers:lookup_argument_stringifier",
        "//tachyon/zk/plonk/halo2/stringifiers:lookup_tracker_stringifier",
        "//tachyon/zk/plonk/halo2/stringifiers:permutation_argument_stringifier",
        "//tachyon/zk/plonk/halo2/stringifiers:phase_stringifier",
        "//tachyon/zk/plonk/halo2/stringifiers:query_stringifier",
        "//tachyon/zk/plonk/halo2/stringifiers:shuffle_argument_stringifier",
    ],
)

tachyon_cc_library(
    name = "pinned_evaluation_domain",
    hdrs = ["pinned_evaluation_domain.h"],
    deps = [
        "//tachyon/base/strings:rust_stringifier",
        "//tachyon/zk/base/entities:entity",
        "//tachyon/zk/plonk/halo2/stringifiers:field_stringifier",
    ],
)

tachyon_cc_library(
    name = "pinned_gates",
    hdrs = ["pinned_gates.h"],
    deps = ["//tachyon/base/strings:rust_stringifier"],
)

tachyon_cc_library(
    name = "pinned_verifying_key",
    hdrs = ["pinned_verifying_key.h"],
    deps = [
        ":pinned_constraint_system",
        ":pinned_evaluation_domain",
        ":pinned_verifying_key_forward",
        "//tachyon/zk/plonk/halo2/stringifiers:permutation_verifying_key_stringifier",
        "//tachyon/zk/plonk/keys:verifying_key",
    ],
)

tachyon_cc_library(
    name = "pinned_verifying_key_forward",
    hdrs = ["pinned_verifying_key_forward.h"],
)

tachyon_cc_library(
    name = "poseidon_transcript",
    hdrs = ["poseidon_transcript.h"],
    deps = [
        ":prime_field_conversion",
        ":proof_serializer",
        "//tachyon/crypto/hashes/sponge/poseidon",
        "//tachyon/crypto/hashes/sponge/poseidon:poseidon_params",
        "//tachyon/crypto/transcripts:transcript",
    ],
)

tachyon_cc_library(
    name = "prime_field_conversion",
    hdrs = ["prime_field_conversion.h"],
    deps = [
        "//tachyon/base/buffer:read_only_buffer",
        "//tachyon/base/types:always_false",
        "//tachyon/math/base:big_int",
        "@com_google_absl//absl/numeric:int128",
    ],
)

tachyon_cc_library(
    name = "proof",
    hdrs = ["proof.h"],
    deps = [
        "//tachyon/zk/lookup:pair",
        "//tachyon/zk/lookup:type",
        "//tachyon/zk/lookup/halo2:verifier_data",
        "//tachyon/zk/lookup/log_derivative_halo2:verifier_data",
        "//tachyon/zk/plonk/permutation:permutation_verifier_data",
        "//tachyon/zk/plonk/vanishing:vanishing_verifier_data",
        "//tachyon/zk/shuffle:verifier_data",
    ],
)

tachyon_cc_library(
    name = "proof_reader",
    hdrs = ["proof_reader.h"],
    deps = [
        ":proof",
        "//tachyon/base:logging",
        "//tachyon/crypto/transcripts:transcript",
        "//tachyon/zk/plonk/keys:verifying_key",
        "//tachyon/zk/plonk/permutation:permutation_utils",
    ],
)

tachyon_cc_library(
    name = "proof_serializer",
    hdrs = ["proof_serializer.h"],
    deps = [
        "//tachyon/base/buffer",
        "//tachyon/math/finite_fields:prime_field_base",
        "//tachyon/math/geometry:affine_point",
    ],
)

tachyon_cc_library(
    name = "prover",
    hdrs = ["prover.h"],
    deps = [
        ":argument_data",
        ":c_prover_impl_base_forward",
        ":random_field_generator",
        ":verifier",
        "//tachyon/base:logging",
        "//tachyon/base:profiler",
        "//tachyon/zk/base/entities:prover_base",
        "//tachyon/zk/lookup:prover",
        "//tachyon/zk/plonk/permutation:permutation_prover",
        "//tachyon/zk/plonk/vanishing:vanishing_prover",
        "//tachyon/zk/shuffle:prover",
    ],
)

tachyon_cc_library(
    name = "prover_test",
    testonly = True,
    hdrs = ["prover_test.h"],
    deps = [
        ":blake2b_transcript",
        ":constants",
        ":prover",
        "//tachyon/crypto/random/xor_shift:xor_shift_rng",
        "//tachyon/math/polynomials/univariate:univariate_evaluation_domain_factory",
        "@com_google_googletest//:gtest",
    ],
)

tachyon_cc_library(
    name = "proving_scheme",
    hdrs = ["proving_scheme.h"],
    deps = [
        ":vendor",
        "//tachyon/zk/lookup:type",
    ],
)

tachyon_cc_library(
    name = "random_field_generator",
    hdrs = ["random_field_generator.h"],
    deps = [
        ":prime_field_conversion",
        "//tachyon/crypto/random:rng",
        "//tachyon/zk/base:random_field_generator_base",
    ],
)

tachyon_cc_library(
    name = "sha256_transcript",
    hdrs = ["sha256_transcript.h"],
    deps = [
        ":constants",
        ":prime_field_conversion",
        ":proof_serializer",
        "//tachyon/crypto/transcripts:transcript",
        "@com_google_boringssl//:crypto",
    ],
)

tachyon_cc_library(
    name = "synthesizer",
    hdrs = ["synthesizer.h"],
    deps = [
        ":witness_collection",
        "//tachyon/zk/base/entities:prover_base",
        "//tachyon/zk/plonk/constraint_system",
    ],
)

tachyon_cc_library(
    name = "snark_verifier_poseidon_transcript",
    hdrs = ["snark_verifier_poseidon_transcript.h"],
    deps = [
        ":prime_field_conversion",
        ":proof_serializer",
        "//tachyon/crypto/hashes/sponge/poseidon",
        "//tachyon/crypto/hashes/sponge/poseidon:poseidon_params",
        "//tachyon/crypto/transcripts:transcript",
    ],
)

tachyon_cc_library(
    name = "transcript_type",
    hdrs = ["transcript_type.h"],
    deps = [
        "//tachyon/base/flag",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "vendor",
    srcs = ["vendor.cc"],
    hdrs = ["vendor.h"],
    deps = [
        "//tachyon:export",
        "//tachyon/base:logging",
        "//tachyon/base/flag",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "verifier",
    hdrs = ["verifier.h"],
    deps = [
        ":proof_reader",
        "//tachyon/base/containers:container_util",
        "//tachyon/zk/base/entities:verifier_base",
        "//tachyon/zk/lookup:verifier",
        "//tachyon/zk/lookup/halo2:opening_point_set",
        "//tachyon/zk/lookup/halo2:utils",
        "//tachyon/zk/plonk/keys:verifying_key",
        "//tachyon/zk/plonk/permutation:permutation_verifier",
        "//tachyon/zk/plonk/vanishing:vanishing_utils",
        "//tachyon/zk/plonk/vanishing:vanishing_verifier",
        "//tachyon/zk/shuffle:opening_point_set",
        "//tachyon/zk/shuffle:utils",
        "//tachyon/zk/shuffle:verifier",
        "@com_google_googletest//:gtest_prod",
    ],
)

tachyon_cc_library(
    name = "witness_collection",
    hdrs = ["witness_collection.h"],
    deps = [
        "//tachyon/base:range",
        "//tachyon/base/containers:container_util",
        "//tachyon/zk/plonk/base:phase",
        "//tachyon/zk/plonk/layout:assignment",
        "@com_google_absl//absl/container:btree",
    ],
)

tachyon_cc_unittest(
    name = "halo2_unittests",
    srcs = [
        "argument_data_unittest.cc",
        "blake2b_transcript_unittest.cc",
        "poseidon_transcript_unittest.cc",
        "prime_field_conversion_unittest.cc",
        "proof_serializer_unittest.cc",
        "proof_unittest.cc",
        "random_field_generator_unittest.cc",
        "sha256_transcript_unittest.cc",
        "snark_verifier_poseidon_transcript_unittest.cc",
        "witness_collection_unittest.cc",
    ],
    deps = [
        ":argument_data",
        ":blake2b_transcript",
        ":bn254_shplonk_prover_test",
        ":poseidon_transcript",
        ":proof",
        ":proof_serializer",
        ":random_field_generator",
        ":sha256_transcript",
        ":snark_verifier_poseidon_transcript",
        ":witness_collection",
        "//tachyon/base:auto_reset",
        "//tachyon/crypto/random/xor_shift:xor_shift_rng",
        "//tachyon/math/elliptic_curves/bn/bn254",
        "//tachyon/math/finite_fields/test:finite_field_test",
        "//tachyon/math/finite_fields/test:gf7",
        "//tachyon/math/polynomials/univariate:univariate_evaluation_domain_factory",
    ],
)
